﻿#include "testcos.h"
#include "src/config/baseexception.h"
#include <QDebug>
#include <QList>
#include <iostream>
using namespace std;
TestCos::TestCos(QObject* parent)
    : QObject(parent)
{}

TestCos::~TestCos() {}

void TestCos::cleanupTestCase()
{

    std::cout << __FUNCTION__ << endl;
}
void TestCos::test_buckets()
{
    try {
        QList<MyBucket> bs = m_cos.buckets();
        QVERIFY(bs.size() > 0);
    }
    catch (BaseException& es) {
        qDebug() << es.msg();
    }
}
void TestCos::test_bucketExists()
{
    bool exists = m_cos.isBucketExists(m_bucketName);
    QVERIFY(exists);
}

void TestCos::initTestCase()
{
    try {
        m_cos.login(m_secretId, m_secretKey);
        std::cout << __FUNCTION__ << endl;
    }
    catch (...) {
    }
}
void TestCos::test_bucketLocation()
{
    QString location = m_cos.getBucketLocation(m_bucketName);
    QCOMPARE(location, "ap-guangzhou");
}

void TestCos::test_putBucket()
{
    /* QSKIP("test_putBucket");*/
    try {
        QString name = "ggdd-1320903609";
        m_cos.putBucket(name, "ap-guangzhou");
        /* bool exist = m_cos.isBucketExists(name);
         QVERIFY(exist);*/
    }
    catch (BaseException& es) {
        qDebug() << es.msg();
    }
}
